<template>
  <div class="comment">
			<div class="title">
				<p class="jiaoliu">交流区({{commentList.length}})</p>
				<div class="pinglun">
					<span class="xiepinglun">写评论</span>
					<span class="pinglin-icon"></span>
				</div>
			</div>
			<div class="comment-list">
				<ul>
					<li class="line border-bottom-last" v-for="(item,index) in commentList" :key="index">
						<div class="avatar border-bottom">
							<div class="left" v-lazy:background-image = "item.head_pic">
							</div>
							<div class="right">
								<div class="right-left">
									<p class="name">{{item.nickname}}</p>
									<p class="time">{{item.create_time*1000 | dateVux(item.create_time*1000)}}</p>
								</div>
								<div class="right-right">
									<div class="replay" @click="replay(index, item.id, item.related_id, type)">
										<div class="huifu">
											<span class="text">回复</span>
											<span class="huifu-icon"></span>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="desc">
							{{item.content}}
						</div>
						<div class="images-wrapper">
							<ul>
								<li class="img" v-for="(img, i) in item.img" :key="i" v-lazy:background-image="img" @click="preview(i)"></li>
							</ul>
						</div>
						<div v-show="i === index && showReplay">
							<comment-pop @passMethod="getData"></comment-pop>
						</div>
					</li>
				</ul>
			</div>
			<mask-show :showMask="showReplay" v-show="showReplay"></mask-show>
		</div>
</template>

<script>
import commentPop from '../common/commentPop'
import maskShow from '../common/maskShow'
import bus from '../../common/js/commonVue'
export default {
  data() {
    return {
      showReplay: false,
      i: ''
    }
  },
  computed: {
    listImage() {
      return this.commentList.img
    }
  },
  components: {
    commentPop,
    maskShow
  },
  props: ['commentList', 'type'],
  mounted() {
    bus.$on('passShowMask', msg => {
      this.showReplay = msg
    })
    bus.$on('passShowMask1', msg => {
      this.showReplay = msg
    })
  },
  methods: {
    preview(index) {
      this.$wechat.previewImage({
        current: this.listImage[index], // 当前显示图片的http链接
        urls: this.listImageSplice // 需要预览的图片http链接列表
      })
    },
    replay(index, everyid, relateid) {
      this.i = index
      this.showReplay = true
      bus.$emit('passId', everyid, relateid, this.type)
    },
    getData() {
      this.$emit('passMethods')
    }
  }
}
</script>

<style lang='scss' scoped>
.comment {
  .line {
    margin: 0 10px;
    padding-bottom: 10px;
  }
  .title {
    height: 40px;
    padding: 0 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    .jiaoliu {
      flex: 1;
    }
    .pinglun {
      flex: 1;
      text-align: right;
      .xiepinglun {
        color: #e17f00;
        vertical-align: middle;
      }
      .pinglin-icon {
        display: inline-block;
        width: 12px;
        height: 12px;
        background-size: 12px 12px;
        background-image: url("../../assets/images/xiepinglun@2x.png");
        vertical-align: middle;
      }
    }
  }
  .avatar {
    display: flex;
    margin: 0 10px;
    padding-bottom: 6px;
    .left {
      flex: 0 0 40px;
      width: 40px;
      height: 40px;
      background-color: #0078e3;
      background-size: cover;
      margin-right: 5px;
      border-radius: 50%;
    }
    .right {
      flex: 1;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .right-left {
        .name {
          font-size: 15px;
          margin-bottom: 6px;
        }
        .time {
          font-size: 12px;
          color: #666;
        }
      }
      .right-right {
        .text {
          font-size: 12px;
          color: #666;
          padding: 0;
        }
        .huifu-icon {
          display: inline-block;
          width: 16px;
          height: 14px;
          // background-color: hotpink;
          background-size: 16px 14px;
          background-image: url("../../assets/images/pinglun@2x.png");
          vertical-align: middle;
        }
      }
    }
  }
  .desc {
    padding: 0 10px 6px 55px;
    font-size: 13px;
    color: #888;
  }
  .images-wrapper {
    box-sizing: border-box;
    margin: 0 10px 0 55px;
    ul {
      width: 100%;
      display: flex;
      .img {
        width: 60px;
        height: 60px;
        background-size: cover;
        margin-right: 10px;
      }
    }
  }
}
</style>
